// 获取用户名
var username = getCookie('username')

// 判断用户是否在如果存在了就继续，如果不存在，强制跳转到登录页

document.querySelector('text').value = username
var btn = document.querySelector('[type="button"]')
btn.onclick = function () {
    sendAjax({
        url: 'http://localhost:8888/users/rpwd',
        method: 'post',
        headers: {
            authorization: localStorage.getItem('token')
        },
        data: {
            id: getCookie('userId'),
            oldPassword: document.querySelector('[name="password"]').value,
            newPassword: document.querySelector('[name="newpassword"]').value,
            rNewPassword: document.querySelector('[name="repassword"]').value
        },

        
        success: res => {
            console.log(res)
            if (res.code === 1) {
                alert(res.message)
                location.href = 'login.html'
            }
        }
    })
}